package comhw1029;

import java.util.Scanner;

public class Item {
    private Book book;
    private int quantity;

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Book whichBook(Book[] book){
        Scanner input = new Scanner(System.in);
        System.out.println("请输入图书编号:");
        int bookID = input.nextInt();
        for(int i = 0; i < book.length; i++){
            if (book[i].getId() == bookID){
                return book[i];
            }
        }
        return null;
    }

    public int howMany(){
        Scanner input = new Scanner(System.in);
        System.out.println("请输入购买数量:");
        int bookQuant = input.nextInt();
        this.setQuantity(bookQuant);
        System.out.println("请继续购买图书");
        return this.getQuantity();
    }

    public Item(Book book, int quantity){
        this.book = book;
        this.quantity = quantity;
    }
    public Item(){

    }
}
